package com.cheyun.netsalev3.view.cluefollowup

import android.util.Log
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.MyAdapter
import com.cheyun.netsalev3.databinding.FragmentLiftCarBinding
import com.cheyun.netsalev3.utils.BaseFragment
import com.cheyun.netsalev3.viewmodel.ClueFollowUpActivityViewModel
import kotlinx.android.synthetic.main.head_layout.view.*


/**
 * 提车
 */
class LiftCarFragment : BaseFragment<FragmentLiftCarBinding>() {
    override fun initContentView(): Int {
        return R.layout.fragment_lift_car
    }

    override fun initViewModel(): ViewModel? {
        activity?.apply {
            return ViewModelProviders.of(this).get(ClueFollowUpActivityViewModel::class.java)
        }
        return super.initViewModel()
    }

    lateinit var adapter: MyAdapter
    override fun initView() {
        adapter = MyAdapter(R.layout.lift_car_fragment_item, binding.viewModel)
        binding.recyclerView.adapter = adapter

    }

    override fun initData() {
        binding.viewModel?.LiftcarViewData?.observe(this, Observer { list ->
            adapter.submitList(list)
        })
        binding.headview?.leftBut?.setOnClickListener {
            binding.viewModel?.clickLeft(it)
        }

        binding.viewModel?.buyBtnEnable?.observe(this, Observer {
            binding.nexBut.isEnabled = it
        })
    }

    override fun lazyInit() {
        Log.i(TAG,"override lazyinit")
    }

}
